package com.maven.front.service.frontTeacher;

import com.maven.front.bean.EduCourse;
import com.maven.front.bean.EduTeacher;
import com.maven.front.bean.SysSubject;
import com.maven.front.mapper.EduCourseMapper;
import com.maven.front.mapper.EduTeacherMapper;
import com.maven.front.mapper.SysSubjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;

import java.util.List;

@Service
public class TeacharService {
    @Autowired
    private SysSubjectMapper sysSubjectMapper;
    @Autowired
    private EduTeacherMapper eduTeacherMapper;
    @Autowired
    private EduCourseMapper eduCourseMapper;

    public List<SysSubject> selectSubject(){
        List<SysSubject> list=sysSubjectMapper.selectSysSubject();
        if(CollectionUtils.isEmpty(list)){
            return  null;
        }
        else {
            return list;
        }
    }

    public List<EduTeacher> getList(){
        List<EduTeacher> list=eduTeacherMapper.getList();
        if(CollectionUtils.isEmpty(list)){
            return null;
        }

        return list;
    }

    public List <EduTeacher> getById(EduTeacher eduTeacher){
       List <EduTeacher> list=eduTeacherMapper.select(eduTeacher);
        if(CollectionUtils.isEmpty(list)){
            return null;
        }
        else {
            return  list;
        }
    }

    public EduTeacher selectKey(int id){
        EduTeacher teacher=eduTeacherMapper.selectByPrimaryKey(id);
        if(ObjectUtils.isEmpty(teacher)){
            return null;
        }
        else {
            return teacher;

        }
    }

    public List<EduCourse> getSubjectId(int subjectId ){
        List<EduCourse> list=eduCourseMapper.getBySubjectId(subjectId);
        if(CollectionUtils.isEmpty(list)){
            return null;
        }
        else {
            return list;
        }
    }
}
